package main

import (
	"fmt"
	"hash/fnv"
	"strconv"
)

type TableName string

// SubTable RS哈希取模分表
func (t TableName) SubTable(id string) string {

	h := fnv.New32a()
	_, _ = h.Write([]byte(id))

	return fmt.Sprintf(
		"%s_%d",
		t, h.Sum32()%10,
	)

}

func main() {
	tb := TableName("user")
	for i := 0; i < 100; i++ {
		fmt.Println(tb.SubTable(strconv.Itoa(i)))
	}
}
